package io.bdmc.modules.sys.service.impl;

import io.bdmc.modules.sys.entity.SysAbout;
import io.bdmc.modules.sys.mapper.SysAboutMapper;
import io.bdmc.modules.sys.service.ISysAboutService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 黄露
 * @since 2020-09-11
 */
@Service
public class SysAboutServiceImpl extends ServiceImpl<SysAboutMapper, SysAbout> implements ISysAboutService {

    @Autowired
    SysAboutMapper aboutMapper;

    @Override
    public boolean deleteAllData() {
        // String sql = "delete from device_alarm;delete from
        // device_alarm_realtime;delete from sys_log;";
        String sql = "delete from device_alarm;delete from device_alarm_realtime;delete from sys_log;"
                + "delete from device_device;delete from device_equipmentroom;delete from device_fibre_match;"
                + "delete from device_fibre_realtime;delete from device_frame;delete from device_link;"
                + "delete from device_link_group;delete from device_machine_disk;delete from device_machine_edfa;"
                + "delete from device_machine_fan;delete from device_machine_fec;delete from device_machine_fec_module;"
                + "delete from device_machine_fms;delete from device_machine_frame;delete from device_machine_fsp;"
                + "delete from device_machine_opm;delete from device_machine_opm_module;delete from device_machine_os;"
                + "delete from device_machine_os_module;delete from device_machine_osw;delete from device_machine_power;"
                + "delete from device_machine_rack;delete from device_machine_remind;delete from device_machine_rfa;"
                + "delete from device_machine_rt;delete from device_measure;delete from device_measure_event;"
                + "delete from device_monitor_dynamic;delete from device_route;delete from device_route_alarm_setting;"
                + "delete from device_route_config;delete from device_route_group;delete from device_route_opm_config;"
                + "delete from device_route_snapshot;delete from device_send_down;delete from device_status_static;"
                + "delete from device_upgrade;delete from fibre_cable;delete from fibre_cable_point;"
                + "delete from fibre_fibre;delete from sys_log;delete from sys_login_history;"
                + "delete from device_alarm_mask;";
        return aboutMapper.deleteDataBySql(sql);
    }

    @Override
    public boolean deleteNoUsedData() {
        String sql = "delete from device_machine_fan where interval_save!=1;"
                + "delete from device_machine_edfa where interval_save!=1;"
                + "delete from device_machine_fec where interval_save!=1;"
                + "delete from device_machine_fec_module where interval_save!=1;"
                + "delete from device_machine_fsp where interval_save!=1;"
                + "delete from device_machine_opm where interval_save!=1;"
                + "delete from device_machine_opm_module where interval_save!=1;"
                + "delete from device_machine_os where interval_save!=1;"
                + "delete from device_machine_os_module where interval_save!=1;"
                + "delete from device_machine_osw where interval_save!=1;"
                + "delete from device_machine_power where interval_save!=1;"
                + "delete from device_machine_rfa where interval_save!=1;"
                + "delete from device_machine_rt where interval_save!=1;";

        return aboutMapper.deleteDataBySql(sql);
    }
}
